package net.sxnic.item.action;

import net.sxnic.item.mdata.Mdata;
import net.sxnic.item.mdata.MdataManager;
import net.sxnic.ugr.UgrActionSupport;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

@SuppressWarnings("serial")
public class ItemModify extends UgrActionSupport {
	
	private Logger logger = LoggerFactory.getLogger(ItemModify.class);
	
	private Mdata mdata;
	private String id;
	
	@Autowired
	protected MdataManager mdManager;
	
	
	public void prepare() throws Exception {
		if (StringUtils.isNotBlank(id)) {
			mdata = mdManager.get(id);
		}

	}
	public String execute() throws Exception{
		
		try {
			logger.debug("实体的计划类别为"+mdata.getSoperCode());
			//获取实体	
			mdManager.save(mdata);	
			
			this.addActionMessage("计划类别修改成功");
			
			//为页面显示准备
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return SUCCESS;
	}
	public Mdata getMdata() {
		return mdata;
	}
	public void setMdata(Mdata mdata) {
		this.mdata = mdata;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

}
